<template>
    <div id="basicInfo">
        <el-form :label-position="labelPosition" 
        label-width="80px" 
        :model="basicInfoFrom">
            <el-form-item :label="v.label" 
                v-for="(v,i) in fromOption" 
                :key=i
                :rules="v.rules[v.props]"
                :prop="v.props"
                >
               <el-input v-model="basicInfoFrom[v.fromKey]"></el-input>
            </el-form-item>
            <!-- 商品分类 -->
            <el-form-item label="商品分类" :rules='rules.rules' prop="goods_cat">
               <goods-cat />
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
export default {
    name:'basicInfo',
    data() {
        return {
            //对齐方式
            labelPosition:'top',
            //form表单数据
            basicInfoFrom: {
                goods_name: '',
                goods_price: '0',
                goods_weight: '0',
                goods_number:'0',
            },
            fromOption:[
                {label:'商品名称',fromKey:'goods_name',props:'goods_name', rules:{
                    goods_name:[
                        { required: true, message: '请输入商品名称', trigger: 'blur' }]
                }},
                {label:'商品价格',fromKey:'goods_price',props:'goods_price',rules:{
                    goods_price:[
                        { required: true, message: '请输入商品价格', trigger: 'blur' }]
                }},
                {label:'商品重量',fromKey:'goods_weight',props:'goods_weight',rules:{
                    goods_weight:[{ required: true, message: '请输入商品重量', trigger: 'blur' }]
                }},
                {label:'商品数量',fromKey:'goods_number',props:'goods_number',rules:{
                    goods_number:[{ required: true, message: '请输入商品数量', trigger: 'blur' }]
                }},
            ],
            rules: [{ required: true, message: '请输入活动名称', trigger: 'blur' }]
        }
    },
    beforeUpdate() {
        //console.log('更新啦')
        this.$store.commit('goods/CHANGE_ADDGOODSQUERY',this.basicInfoFrom)
    },
    
}
</script>
<style lang="scss" scoped>
    #basicInfo{

    }
</style>